<template name="sendcar">
	<!--选择库间移位申请列表、选择库间移出列表 -->
	<view class="mypage">
		<view class="cu-bar search bg-white">
			<view class="search-form round">
				<text class="cuIcon-search"></text>
				<input type="text" v-model="keyword" placeholder="输入单号" />
			</view>
			<view class="action">
				<button class="cu-btn bg-blue shadow-blur round">搜索</button>
			</view>
		</view>
		
		<view class="card-list-wrapper">
			<view class="card-list-row radius shadow-warp bg-white margin-top" v-for="(item,index) in planList" :key="index"  @click="openDetail(0)">				
				<view class="flex-just-between bottom-border top-wrap">
					<text class="text-blue text-bold">{{ label01 }}：{{ item.BILLNO }}</text>
					<view class="cu-capsule radius">
						<view class='cu-tag bg-blue sm'>
							<text class='cuIcon-medal'></text>
						</view>
						<view class="cu-tag line-brown sm">
							{{ index+1}}
						</view>
					</view>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-red"></text>
					<text class="card-label text-black">单据编号：</text>
					<text>{{ item.BILLNO || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-red"></text>
					<text class="card-label text-black">集团：</text>
					<text>{{ item.GROUPNAME || '' }}</text>
				</view>
				<view v-if="type=='M1017'">
					<view class="card-list-row-1">
						<text class="cuIcon-title text-red"></text>
						<text class="card-label text-black">组织：</text>
						<text>{{ item.ORGNAME || '' }}</text>
					</view>
					
					<view class="card-list-row-1">
						<text class="cuIcon-title text-green"></text>
						<text class="card-label text-black">移出仓库：</text>
						<text>{{ item.STORENAME || '' }}</text>
					</view>
					<view class="card-list-row-1">
						<text class="cuIcon-title text-green"></text>
						<text class="card-label text-black">移入仓库：</text>
						<text>{{ item.INSTORENAME || '' }}</text>
					</view>	
				</view>
				
				
				
				<view v-if="type=='M1018'">
					<view class="card-list-row-1">
						<text class="cuIcon-title text-red"></text>
						<text class="card-label text-black">移出组织：</text>
						<text>{{ item.ORGNAME || '' }}</text>
					</view>
					
					<view class="card-list-row-1">
						<text class="cuIcon-title text-green"></text>
						<text class="card-label text-black">移出仓库：</text>
						<text>{{ item.STORENAME || '' }}</text>
					</view>
					<view class="card-list-row-1">
						<text class="cuIcon-title text-red"></text>
						<text class="card-label text-black">移入组织：</text>
						<text>{{ item.INORGNAME || '' }}</text>
					</view>
					<view class="card-list-row-1">
						<text class="cuIcon-title text-green"></text>
						<text class="card-label text-black">移入仓库：</text>
						<text>{{ item.INSTORENAME || '' }}</text>
					</view>	
					<view class="card-list-row-1">
						<text class="cuIcon-title text-green"></text>
						<text class="card-label text-black">移入人：</text>
						<text>{{ item.INMOVER || '' }}</text>
					</view>	
					<view class="card-list-row-1">
						<text class="cuIcon-title text-green"></text>
						<text class="card-label text-black">移出人：</text>
						<text>{{ item.MOVER || '' }}</text>
					</view>	
				</view>
							
				<view class="card-list-row-1">
					<text class="cuIcon-title text-gray"></text>
					<text class="card-label text-black">日期：</text> 
					<text>{{ item.BILLDATE || '' }}</text>
				</view>	
				
			</view>
		
		</view>
		
	</view>

</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import api from '@/common/api.js'
	let _self, page=1, total=1, originalTitle,type,query = {};
	
	export default {
		computed: mapState(['userInfo','baseUrl']),
		data() {
			return {
				title:'',
				type:'',
				keyword:'',
				planList: [],
				label01: '订单'
			};
		},
		onLoad(params) {
			_self = this; 			
			page = 1;
			total = 1 ;	
			_self.type=params.type;
			originalTitle = params.type=='M1018' ? '移出单列表(' : '列表' ;
			_self.getNewsList(_self.type);
		},
		//下拉刷新
		onPullDownRefresh : function(){
			// 重置分页及数据
			page = 1;
			total = 1 ;
			this.getNewsList();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
			uni.showToast({"title":"数据已刷新", icon:"none"});
		},
		// 加载更多
		onReachBottom : function(){
			this.getNewsList();
		}, 
		methods:{
			getNewsList(int){
				console.log(int);
				if(page>total){return uni.showToast({
					icon:'none',
					title:'没有数据了。'
				})}
				
				if(int=="M1017"){
					query = {
							"category":'ST_MOVEAPPLY', 
							"page":1,
							"rows":5,
							"sidx":"",
							"sord":"",
							"queryJson":{ISFINISH: 0,BILLSTATUS:1,BTYPE:1},
							"userId":"",
							"account":"admin",
					}
					}else if(int=='M1018'){
						query = {
								"category":'ST_MOVE', 
								"page":1,
								"rows":5,
								"sidx":"",
								"sord":"",
								"queryJson":{BTCATEGORY: 1,BILLSTATUS: 1,MOVETYPE: 0},
								"userId":"",
								"account":"admin",
								}
					}
			
				query.page = page ;
			/* 	console.log(query);
				 console.log(_self.baseUrl + api.apiPublic.getOrderList); */
				this.axios({
					url: api.apiPublic.getOrderList ,
					data: query ,
					isLoading: 1
				}).then(res=>{
					let { Result } = res ;
					if( page == 1){
						_self.planList = Result.rows;
						let pagetitle = originalTitle +Result.records +')';
						_self.$utils.setPageTitle(pagetitle)
					}else{
						_self.planList = _self.planList.concat(Result.rows);
					}
					total = res.data.total;
					page++;
				}) 
			},
			openDetail:function(e){
				/* console.log( _self.planList[e].BILLNO); */
				let url = '/pages/tab04/submit2?id=' 
				  + _self.planList[e].BILLNO +'&dbt='
					+ query.category +'&t='+type+"&type="+_self.type+'&item='+encodeURIComponent(JSON.stringify(_self.planList[e]));
				uni.navigateTo({
					url:  url 
				})
			}
		}
	}
</script>

<style scoped>
	
	.card-list-wrapper {
		width: 710upx;
		height: 100upx;
		margin: 0 auto;
	}

	.card-list-row {
		padding: 20upx;
	}

	.card-list-row-1 {
		padding: 10upx 0;
	}
	.card-label{
		display: inline-block;
		width: 150upx;
	}
	.top-border{
		border-top: 1upx solid rgba(0,0,0,.1);
	}
	.top-wrap{
		padding-bottom: 20upx;
		margin-bottom: 20upx;
	}
	.bottom-border{
		border-bottom: 1upx solid rgba(0,0,0,.1);
	}
	.btn-wrap{
		padding-top: 20upx;
	}
</style>
